<?php if(!defined('GbIncl2')){?>
<meta http-equiv="refresh" content="0;url=../spm-itats/block.php" />
<?php } else { ?>
	<?php
    $_GET['set']=isset($_GET['set']) ? $_GET['set'] :'';
	$_GET['audit']=isset($_GET['audit']) ? $_GET['audit'] :''; 
	if ($_SESSION['AUDIT']=='1'){ ?>
    
    <div class="section">
    <ul class="nice-list">
        <li>
        	<?php if ($_GET['audit']=='agenda'){ echo "<a href=?setting=audit&amp;audit=agenda>"?><b>AGENDA KEGIATAN</b></a> |
            <?php }else{ echo "<a href=?setting=audit&amp;audit=agenda>"?>AGENDA KEGIATAN</a> |
            <?php }?> 
            <?php if ($_GET['audit']=='borang'){ echo "<a href=?setting=audit&amp;audit=borang>"?><b>BORANG</b></a> |
            <?php }else{ echo "<a href=?setting=audit&amp;audit=borang>"?>BORANG</a> |
            <?php }?>
            <?php if ($_GET['audit']=='akademik'){ echo "<a href=?setting=audit&amp;audit=akademik>"?><b>AKADEMIK</b></a> |
            <?php }else{ echo "<a href=?setting=audit&amp;audit=akademik>"?>AKADEMIK</a> |
            <?php }?>
        </li>
        <?php //AWAL TAMPIL TABEL MASING MASING//?>
        <?php if ($_GET['audit']=='agenda'){?>
        <li>
            <table width="100%" border="2">
              <tr class="even">
                <td width="10%">ID</td>
                <td width="55%">JUDUL</td>
                <td width="10%">TGL UPLOAD</td>
                <td width="15%">UPLOADER</td>
                <td width="10%">PENGATURAN</td>
              </tr>
			  <?php $AAGENDA=mysql_query("select * from AUDIT_AGENDA_KEGIATAN_SPM ORDER BY ID_AAKS ASC");$CAAGENDA=mysql_query("select COUNT(*) AS CAAGENDA from AUDIT_AGENDA_KEGIATAN_SPM");$CAAGENDA=mysql_fetch_assoc($CAAGENDA);
			  while ($DATAAGENDA=mysql_fetch_array($AAGENDA)){?>
              <tr>
                <td><?php echo $DATAAGENDA['ID_AAKS'] ?></td>
                <td><?php echo $DATAAGENDA['JUDUL_AAKS'] ?></td>
                <td><?php echo $DATAAGENDA['TANGGAL_AAKS'] ?></td>
                <td><?php echo $DATAAGENDA['ID_US'] ?></td>
                <td>
                    <?php 
					$dlinkid=$DATAAGENDA['ID_AAKS'];
					$elinkid=substr(md5($DATAAGENDA['ID_AAKS']),8,8);
                    echo "<a href=?setting=audit&amp;audit=agenda&amp;id=$dlinkid&amp;set=02>";?>edit</a> | 
                    <?php echo "<a href=?setting=audit&amp;audit=agenda&amp;id=$dlinkid&amp;set=03>";?> delete</a>
                </td>
              </tr> 
			  <?php } ?>
              <tr>
                <td colspan="5"><?php echo "<a href=?setting=audit&amp;audit=agenda&amp;set=01>";?>tambah data</a></td>
              </tr>
            </table>
        </li>
        
        <?php }else if ($_GET['audit']=='borang'){?>
        <li>
            <table width="100%" border="2">
              <tr class="even">
                <td width="10%">ID</td>
                <td width="50%">NAMA FILE</td>
                <td width="10%">TGL UPLOAD</td>
                <td width="15%">UPLOADER</td>
                <td width="15%">PENGATURAN</td>
              </tr>
			  <?php $ABORANG=mysql_query("select * from AUDIT_UPLOAD_SPM where ID_AUS LIKE 'A1%' ORDER BY ID_AUS ASC");$CABORANG=mysql_query("select ID_AUS from AUDIT_UPLOAD_SPM ORDER BY ID_AUS DESC LIMIT 1");
			  $CABORANG=mysql_fetch_assoc($CABORANG);
			  $CABORANG['ID_AUS']=(int)substr($CABORANG['ID_AUS'],6,4);
			  //$CABORANG['ID_AUS']= int($CABORANG['ID_AUS']);
			  //echo $CABORANG['ID_AUS'];
			  while ($DATAABORANG=mysql_fetch_array($ABORANG)){?>
              <tr>
                <td><?php echo $DATAABORANG['ID_AUS'] ?></td>
                <td><?php echo $DATAABORANG['NAMA_AUS'] ?></td>
                <td><?php echo $DATAABORANG['TANGGAL_AUS'] ?></td>
                <td><?php echo $DATAABORANG['ID_US'] ?></td>
                <td>
                    <?php 
					$dlinkid=$DATAABORANG['ID_AUS'];
					$elinkid=substr(md5($DATAABORANG['ID_AUS']),8,8);
					echo "<a href=?setting=audit&amp;audit=borang&amp;id=$dlinkid&amp;set=04>";?>view</a> |  
                    <?php
                    echo "<a href=?setting=audit&amp;audit=borang&amp;id=$dlinkid&amp;set=02>";?>edit</a> | 
                    <?php echo "<a href=?setting=audit&amp;audit=borang&amp;id=$dlinkid&amp;set=03>";?> delete</a>
                </td>
              </tr> 
			  <?php } ?>
              <tr>
                <td colspan="5"><?php echo "<a href=?setting=audit&amp;audit=borang&amp;set=01>";?>tambah data</a></td>
              </tr>
            </table>
        </li>
        
		<?php }else if ($_GET['audit']=='akademik'){?>
        <li>
            <table border="1">
              <tr class="even">
                <td width="5%">ID</td>
                <td width="25%">JUDUL</td>
                <td width="65%">LINK</td>
                <td width="5%">PENGATURAN</td>
              </tr>
			  <?php $TDIKTI=mysql_query("select * from AUDIT_UPLOAD_SPM where ID_PARENTDS='02' ORDER BY ID_DS ASC"); $CKDIKTI=mysql_query("select COUNT(*) AS CKDIKTI from AUDIT_UPLOAD_SPM where ID_PARENTDS=2"); $CKDIKTI=mysql_fetch_assoc($CKDIKTI); 
			  while ($DATATDIKTI=mysql_fetch_array($TDIKTI)){?>
              <tr>
                <td><?php echo $DATATDIKTI['ID_DS'] ?></th>
                <td><?php echo $DATATDIKTI['NAMA_DS'] ?></td>
                <td><?php echo substr($DATATDIKTI['LINK_DS'],0,50) ?></td>
                <td>
                    <?php 
					$dlinkidd=$DATATDIKTI['ID_DS'];
					$elinkidd=md5($DATATDIKTI['ID_DS']);
                    echo "<a href=?setting=audit&amp;audit=akademik&amp;id1=$elinkidd&amp;id2=$dlinkidd&amp;set=02>";?>edit</a> | 
                    <?php echo "<a href=?setting=audit&amp;audit=akademik&amp;id=$elinkidd&amp;set=03>";?> delete</a>
                </td>
              </tr> 
			  <?php } ?>
              <tr>
                <td colspan="5"><?php echo "<a href=?setting=audit&amp;audit=akademik&amp;set=01>";?>tambah data</a></td>
              </tr>
               </table>
        </li>
        
        <?php } else { ?>
        	<meta http-equiv="refresh" content="0;url=../cpanel/?setting=audit&amp;audit=agenda" />
        <?php }	?>
        <?php //AKHIR TAMPIL TABEL MASING MASING//?>
        
        <?php //AWAL FORM INSERT//?>
        <?php 
        if ($_GET['set']=='01' and $_GET['audit']=='agenda'){?>
        <form id="f_s_audit_agenda" name="f_s_audit_agenda" method="post" action="">
        <?php echo gmdate("d-M-Y", time());?>
          <table width="100%" border="2">
            <tr>
              <th scope="row" width="10%"><label for="t_d_id">ID</label></th>
              <th width="90%">
			  <?php if(strlen ($CAAGENDA['CAAGENDA']+1)==1){
				  echo "01-000"; echo $CAAGENDA['CAAGENDA']+1;
				  }else if(strlen ($CAAGENDA['CAAGENDA']+1)==2){
				  echo "01-00"; echo $CAAGENDA['CAAGENDA']+1;
				  }else if(strlen ($CAAGENDA['CAAGENDA']+1)==3){
				  echo "01-0"; echo $CAAGENDA['CAAGENDA']+1;
				  }else if(strlen ($CAAGENDA['CAAGENDA']+1)==4){
				  echo "01-"; echo $CAAGENDA['CAAGENDA']+1;
				  }
			?></th>
            </tr>
            <tr>
              <th scope="row"><label for="t_d_judul">JUDUL(*)</label></th>
              <th><input type="text" class="text" size="27" name="t_d_judul" id="t_d_judul" /></th>
            </tr>
            <tr>
              <th scope="row"><label for="t_d_nama">DETAIL(*)</label></th>
              <th><input type="text" class="text" size="27" name="t_d_nama" id="t_d_nama" /></th>
            </tr>
            <tr>
              <th scope="row">&nbsp;</th>
              <th class="left"><input type="submit" name="submit" id="b_d_insert" class="button" value="Tambah" /></th>
            </tr>
          </table>
        </form>
        <?php //AKHIR FORM INSERT//?>
        
        <?php //AWAL FORM INSERT//?>
        <?php 
		}else if ($_GET['set']=='01' and $_GET['audit']=='borang'){?>
        <form id="f_s_audit_borang" name="f_s_audit_borang" method="post" action="">
        <?php echo gmdate("d-M-Y", time());?>
          <table width="100%" border="2">
            <tr>
              <th scope="row" width="10%"><label for="t_d_id">ID</label></th>
              <th width="90%">
			  <?php if(strlen ($CABORANG['ID_AUS']+1)==1){
				  echo "A1-06-000"; echo $CABORANG['ID_AUS']+1;
				  }else if(strlen ($CABORANG['ID_AUS']+1)==2){
				  echo "A1-06-00"; echo $CABORANG['ID_AUS']+1;
				  }else if(strlen ($CABORANG['ID_AUS']+1)==3){
				  echo "A1-06-0"; echo $CABORANG['ID_AUS']+1;
				  }else if(strlen ($CABORANG['ID_AUS']+1)==4){
				  echo "A1-06-"; echo $CABORANG['ID_AUS']+1;
				  }
			?></th>
            </tr>
            <tr>
              <th scope="row"><label for="t_d_judul">JUDUL(*)</label></th>
              <th><input type="text" class="text" size="27" name="t_d_judul" id="t_d_judul" /></th>
            </tr>
            <tr>
              <th scope="row">&nbsp;</th>
              <th class="left"><input type="submit" name="submit" id="b_d_insert" class="button" value="Tambah" /></th>
            </tr>
          </table>
        </form>
        <?php //AKHIR FORM INSERT//?>
        
        <?php //AWAL DELETE//?>
        <?php }else if ($_GET['set']=='03' and $_GET['audit']=='agenda'){
			$id=$_GET['id'];
			$deleteaudit = "DELETE FROM AUDIT_AGENDA_KEGIATAN_SPM WHERE ID_AAKS='$id' LIMIT 1";
			$hasildeleteaudit = mysql_query($deleteaudit);
			if ($hasildeleteaudit){
				echo "<p>Proses Hapus Sukses .</p>";?>
				<meta http-equiv="refresh" content="0;url='../cpanel/?setting=audit&amp;audit=agenda'"><?php
			}else echo "<p>Proses Hapus Gagal</p>";?>
        <?php //AKHIR DELETE//?>
        
        <?php //AWAL DELETE//?>
        <?php }else if ($_GET['set']=='03' and $_GET['audit']=='borang'){
			$id=$_GET['id'];
			$deleteaudit = "DELETE FROM AUDIT_UPLOAD_SPM WHERE ID_AUS='$id' LIMIT 1";
			$hasildeleteaudit = mysql_query($deleteaudit);
			if ($hasildeleteaudit){
				echo "<p>Proses Hapus Sukses .</p>";?>
				<meta http-equiv="refresh" content="0;url='../cpanel/?setting=audit&amp;audit=borang'"><?php
			}else echo "<p>Proses Hapus Gagal</p>";?>
        <?php //AKHIR DELETE//?>
        
        <?php //AWAL VIEW//?>
        <?php }else if ($_GET['set']=='04'){
			if ($_GET['audit']=='borang'){
				$idpdf=$dlinkid;
			}else if ($_GET['audit']=='akademik'){
				$idp=2;
				$idd=$_GET['idd'];
			}
			$viewaudit = "SELECT ID_AUS, FILE_AUS FROM AUDIT_UPLOAD_SPM WHERE ID_AUS='$idpdf' LIMIT 1";
			$data = mysql_query($viewaudit);
			$data=mysql_fetch_array($data);
			$hasilnama=$data[0];
			$hasilviewaudit=$data[1];
			if ($hasilviewaudit){
				echo 'PDF VIEWER 1 <a href=?setting=audit&amp;audit=borang&amp;id=$elinkid&amp;set=04 target="_blank">DOWNLOAD</a><embed width=100% height=100% type="application/pdf" title="'; echo "$hasilnama.pdf"; echo'" src="data:application/pdf;base64,'.base64_encode($hasilviewaudit).'" src="toolbar=0&amp;navpanes=0&amp;scrollbar=0"></embed>';			
				echo "<p>Proses Lihat Sukses .</p>";?>
				<!--<meta http-equiv="refresh" content="0;url='../cpanel/?setting=audit&amp;audit=borang'">--><?php
			}else echo "<p>Proses Lihat Gagal</p>";?>
        <?php } ?>
        <?php //AKHIR DELETE//?>
        
        <?php //AWAL INSERT//?>
        <!--<embed title="test.pdf" src="../backup/Doc1.pdf#toolbar=0&navpanes=0&scrollbar=0" width="100%" height="100%"></embed>-->
        <?php
        if ($_GET['set']=='01' and $_GET['audit']=='agenda' and isset($_POST['t_d_judul']) and isset($_POST['t_d_nama'])){
            if(strlen ($CAAGENDA['CAAGENDA']+1)==1){
				$nomer=$CAAGENDA['CAAGENDA']+1;
				$id = "01-000$nomer";
			}else if(strlen ($CAAGENDA['CAAGENDA']+1)==2){
				$nomer=$CAAGENDA['CAAGENDA']+1;
				$id = "01-00$nomer";
			}else if(strlen ($CAAGENDA['CAAGENDA']+1)==3){
				$nomer=$CAAGENDA['CAAGENDA']+1;
				$id = "01-0$nomer";
			}else if(strlen ($CAAGENDA['CAAGENDA']+1)==4){
				$nomer=$CAAGENDA['CAAGENDA']+1;
				$id = "01-$nomer";
			}
			$tanggal=strtoupper(date("d-M-Y", time()));
			$insertagenda = "INSERT INTO AUDIT_AGENDA_KEGIATAN_SPM VALUES ('$id','$_POST[t_d_judul]','$_POST[t_d_nama]','$tanggal','','')";
            $hasilinsertagenda = mysql_query($insertagenda);
            if ($hasilinsertagenda){
                echo "<p>Proses Input Sukses .</p>";?>
                <meta http-equiv="refresh" content="0;url='../cpanel/?setting=audit&amp;audit=agenda'">
            <?php }else echo "<p>Proses Input Gagal - $id</p>";?>
            
       <?php }else if ($_GET['set']=='01' and $_GET['audit']=='borang' and isset($_POST['t_d_judul'])){
            if(strlen ($CABORANG['ID_AUS']+1)==1){
				$nomer=$CABORANG['ID_AUS']+1;
				$id = "A1-06-000$nomer";
			}else if(strlen ($CABORANG['ID_AUS']+1)==2){
				$nomer=$CABORANG['ID_AUS']+1;
				$id = "A1-06-00$nomer";
			}else if(strlen ($CABORANG['ID_AUS']+1)==3){
				$nomer=$CABORANG['ID_AUS']+1;
				$id = "A1-06-0$nomer";
			}else if(strlen ($CABORANG['ID_AUS']+1)==4){
				$nomer=$CABORANG['ID_AUS']+1;
				$id = "A1-06-$nomer";
			}
			$tanggal=strtoupper(date("d-M-Y", time()));
			$insertborang = "INSERT INTO AUDIT_UPLOAD_SPM VALUES ('$id','','','$tanggal','0','')";
            $hasilinsertborang = mysql_query($insertborang);
            if ($hasilinsertborang){
                echo "<p>Proses Input Sukses .</p>";?>
                <meta http-equiv="refresh" content="0;url='../cpanel/?setting=audit&amp;audit=borang'">
            <?php }else echo "<p>Proses Input Gagal - $id</p>";?>
        <?php } else "error";?>
        <?php //AKHIR INSERT//?>	
    </ul>
    </div>
	<?php }else {?>
    	<meta http-equiv="refresh" content="0;url=block.php" />
    <?php }?>
<?php }?>

<?php
/*

*/
?>